

*****
***83 
*****

gen top = .
gen top_1 =.

gen inc83 = hhincome_n

tab inc83 if inc83 == 11 & year == 1983
replace top = r(N)
tab inc83 if inc83 == 10 & year == 1983
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(15000) - ln(13500))
gen test = 15000 * (1 + (V/(V - 1)))
drop V

recode inc83 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (0 98 99 = .) if year == 1983
replace inc83 = test if inc83 == 11 & year == 1983
replace inc83 = . if year !=1983

drop test

gen Einc83 = (inc83) /(sqrt(househld))

xtile incquint83= Einc83 [pw=wtfactor], n(5)


*****
** 84
******


gen inc84 = hhincome_n

tab inc84 if inc84 == 11 & year == 1984
replace top = r(N)
tab inc84 if inc84== 10 & year == 1984
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(15000) - ln(13500))
gen test = 15000 * ( 1 + (V/(V - 1)))
drop V

recode inc84 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (0 98 99 = .) if year == 1984
replace inc84 = test if inc84 == 11 & year == 1984
replace inc84 = . if year !=1984

drop test

gen Einc84 = (inc84) /sqrt(househld)

xtile incquint84= Einc84[pw=wtfactor], n(5)



****
**85
****

gen inc85 = hhincome_n

tab inc85 if inc85 == 11  & year == 1985
replace top = r(N)
tab inc85 if inc85 == 10  & year == 1985
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(15000) - ln(13500))
gen test = 15000 * (1 + (V/(V - 1)))
drop V

recode inc85 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (0 98 99 = .) if year == 1985
replace inc85 = test if inc85 == 11 & year == 1985
replace inc85 = . if year !=1985

drop test

gen Einc85 = (inc85) /sqrt(househld)

xtile incquint85= Einc85[pw=wtfactor], n(5)


*****
**86
*****


gen inc86 = hhincome_n

tab inc86 if inc86 == 13  & year == 1986
replace top = r(N)
tab inc86 if inc86== 12  & year == 1986 
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(20000) - ln(19000))
gen test = 20000 * (1 + (V/(V - 1)))
drop V

recode inc86 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (11 = 16500) (12 = 19000)  (0 98 99 = .) if year == 1986
replace inc86 = test if inc86 == 13 & year == 1986
replace inc86 = . if year !=1986

drop test

gen Einc86 = (inc86) /sqrt(househld)

xtile incquint86= Einc86[pw=wtfactor], n(5)

********
**** 87
*******

gen inc87 = hhincome_n

tab inc87 if inc87 == 13 & year == 1987
replace top = r(N)
tab inc87 if inc87 == 12 & year == 1987
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(20000) - ln(19000))
gen test = 20000 * (1 + (V/(V - 1)))
drop V

recode inc87 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (11 = 16500) (12 = 19000) (0 98 99 = .) if year == 1987
replace inc87 = test if inc87 == 13 & year == 1987
replace inc87 = . if year !=1987
drop test

gen Einc87 = (inc87) /sqrt(househld)

xtile incquint87= Einc87[pw=wtfactor], n(5)


*******
**** 89
********

gen inc89 = hhincome_n

tab inc89 if inc89 == 14 & year == 1989
replace top = r(N)
tab inc89 if inc89 == 13 & year == 1989
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(23000) - ln(21500))
gen test = 23000 * (1 + (V/(V - 1)))
drop V

recode inc89 (1 = 1000) (2 = 2500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (11 = 16500) (12 = 19000) (13 = 21500) (0 98 99 = .)  if year == 1989
replace inc89 = test if inc89 == 14 & year == 1989
replace inc89 = . if year !=1989
drop test


gen Einc89 = (inc89 ) /sqrt(househld)

xtile incquint89= Einc89[pw=wtfactor], n(5)


****
**90
****

gen inc90 = hhincome_n

tab inc90 if inc90 == 17 & year == 1990
replace top = r(N)
tab inc90 if inc90 == 16 & year == 1990
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(32000) - ln(30500))
gen test = 32000 * (1 + (V/(V - 1)))
drop V

recode inc90 (2 = 1500) ( 3= 3500 ) ( 4= 4500) ( 5= 5500) ( 6= 6500) ( 7=7500) ( 8=9000) ( 9=11000) (10 = 13500) (11 = 16500) (12 = 19000) (13 = 21500) (14 = 24500) (15 = 27500) (16 = 30500) (0 98 99 = .)  if year == 1990
replace inc90 = test if inc90 == 17 & year == 1990
replace inc90 = . if year !=1990
drop test

gen Einc90 = (inc90 ) /sqrt(househld)

xtile incquint90= Einc90[pw=wtfactor], n(5)


*******
*** 91
*******

gen inc91 = hhincome_n

tab inc91 if inc91 == 18 & year == 1991
replace top = r(N)
tab inc91 if inc91 == 17 & year == 1991
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(35000) - ln(33500))
gen test = 35000 * (1 + (V/(V - 1)))
drop V

recode inc91  ( 3= 2000 )  ( 5= 5000) ( 7=7000) ( 8=9000) ( 9=11000) (10 = 13500) (11 = 16500) (12 = 19000) (13 = 21500) (14 = 24500) (15 = 27500) (16 = 30500) (17= 33500) (0 98 99 = .)  if year == 1991
replace inc91 = test if inc91 == 18 & year == 1991
replace inc91 = . if year !=1991
drop test

gen Einc91 = (inc91  ) /sqrt(househld)

xtile incquint91= Einc91[pw=wtfactor], n(5)

****
****93
****


gen inc93 = hhincome_n

tab inc93 if inc93 == 20 & year == 1993
replace top = r(N)
tab inc93 if inc93  == 19 & year == 1993
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(41000) - ln(39500))
gen test = 39500 * (1 + (V/(V - 1)))
drop V


recode inc93 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (-1 98 99 = .)  if year == 1993
replace inc93 = test if inc93 == 20 & year == 1993
replace inc93 = . if year !=1993
drop test

gen Einc93 = (inc93  ) /sqrt(househld)

xtile incquint93= Einc93[pw=wtfactor], n(5)

*******
**** 94
*******


gen inc94 = hhincome_n

tab inc94 if inc94 == 20 & year == 1994
replace top = r(N)
tab inc94 if inc94 == 19 & year == 1994
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(41000) - ln(39500))
gen test = 41000 * (1 + (V/(V - 1)))
drop V

recode inc94  (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (-1 98 99 = .) if year == 1994
replace inc94 = test if inc94 == 20 & year == 1994
replace inc94 = . if year !=1994
drop test

gen Einc94 = (inc94  ) /sqrt(househld)

xtile incquint94= Einc94[pw=wtfactor], n(5)

*******
**** 95
*******

gen inc95 = hhincome_n

tab inc95 if inc95 == 20 & year == 1995
replace top = r(N)
tab inc95 if inc95 == 19 & year == 1995
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(41000) - ln(39500))
gen test = 41000 * (1 + (V/(V - 1)))
drop V

recode inc95  (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (-1 98 99 = .) if year == 1995
replace inc95 = test if inc95 == 20 & year == 1995
replace inc95 = . if year !=1995
drop test

gen Einc95 = (inc95 ) /sqrt(househld)

xtile incquint95= Einc95[pw=wtfactor], n(5)


*****
***96
*****


gen inc96 = hhincome_n

tab inc96 if inc96 == 20 & year == 1996
replace top = r(N)
tab inc96 if inc96 == 19 & year == 1996
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(41000) - ln(39500))
gen test = 41000 * (1 + (V/(V - 1)))
drop V

recode inc96 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (-1 98 99 = .) if year == 1996
replace inc96 = test if inc96 == 20 & year == 1996
replace inc96 = . if year !=1996
drop test

gen Einc96 = (inc96  ) /sqrt(househld)

xtile incquint96= Einc96[pw=wtfactor], n(5)

*****
*** 97 [outcome variables not available]
*****


*******
*** 98
******


gen inc98 = hhincome_n

tab inc98 if inc98 == 21 & year == 1998
replace top = r(N)
tab inc98 if inc98 == 20 & year == 1998
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(44000) - ln(42500))
gen test = 41000* (1 + (V/(V - 1)))
drop V

recode inc98 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (20 = 42500) (-1 98 99 = .)  if year == 1998
replace inc98 = test if inc98 == 21 & year == 1998
replace inc98 = . if year !=1998
drop test

gen Einc98 = (inc98) /sqrt(househld)

xtile incquint98= Einc98[pw=wtfactor], n(5)


*******
**** 99
*******


gen inc99 = hhincome_n

tab inc99 if inc99 == 22 & year == 1999
replace top = r(N)
tab inc99 if inc99 == 21 & year == 1999
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(47000) - ln(45500))
gen test = 47000* (1 + (V/(V - 1)))
drop V

recode inc99 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (20 = 42500) (21 = 45500) (-1 98 99 = .) if year == 1999
replace inc99 = test if inc99 == 22 & year == 1999
replace inc99 = . if year !=1999
drop test

gen Einc99 = (inc99  ) /sqrt(househld)

xtile incquint99= Einc99[pw=wtfactor], n(5)



*******
**** 00
*******


gen inc00 = hhincome_n

tab inc00 if inc00 == 23 & year == 2000
replace top = r(N)
tab inc00 if inc00 == 22 & year == 2000
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(50000) - ln(48500))
gen test = 50000* (1 + (V/(V - 1)))
drop V

recode inc00 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (20 = 42500) (21 = 45500) (22= 48500) (-1 98 99 = .) if year == 2000
replace inc00 = test if inc00 == 23 & year == 2000
replace inc00 = . if year != 2000
drop test

gen Einc00 = (inc00  ) /sqrt(househld)

xtile incquint00= Einc00[pw=wtfactor], n(5)


*******
**** 01
*******

gen inc01 = hhincome_n

tab inc01 if inc01 == 24 & year == 2001
replace top = r(N)
tab inc01 if inc01  == 23 & year == 2001
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(53000) - ln(51500))
gen test = 53000* (1 + (V/(V - 1)))
drop V

recode inc01 (3 = 2000) (5 = 5000) ( 7= 7000 ) ( 8= 9000) ( 9= 1100) ( 10= 13500) ( 11=16500) ( 12=19000) ( 13=21500) (14= 24500) (15 = 27500) (16 = 30500) (17 = 33500) (18 = 36500) (19 = 39500) (20 = 42500) (21 = 45500) (22= 48500) (23=51500) (-1 98 99 = .) if year == 2001
replace inc01 = test if inc01 == 24 & year == 2001
replace inc01 = . if year != 2001
drop test

gen Einc01 = (inc01 ) /sqrt(househld)

xtile incquint01= Einc01[pw=wtfactor], n(5)


*******
**** 02
*******


gen inc02 = hhincome_n

tab inc02 if inc02 == 17 & year == 2002
replace top = r(N)
tab inc02 if inc02 == 16 & year == 2002
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc02 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2002
replace inc02 = test if inc02 == 17 & year == 2002
replace inc02 = . if year != 2002
drop test

gen Einc02 = (inc02 ) /sqrt(househld)

xtile incquint02= Einc02[pw=wtfactor], n(5)


*******
**** 03
*******



gen inc03 = hhincome_n

tab inc03 if inc03 == 17 & year == 2003
replace top = r(N)
tab inc03 if inc03 == 16 & year == 2003
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc03 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2003
replace inc03 = test if inc03 == 17 & year == 2003
replace inc03 = . if year != 2003
drop test

gen Einc03 = (inc03 ) /sqrt(househld)

xtile incquint03= Einc03[pw=wtfactor], n(5)



*******
**** 04
*******


gen inc04 = hhincome_n

tab inc04 if inc04 == 17 & year == 2004
replace top = r(N)
tab inc04 if inc04 == 16 & year == 2004
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc04 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2004
replace inc04 = test if inc04 == 17 & year == 2004
replace inc04 = . if year != 2004
drop test

gen Einc04 = (inc04 ) /sqrt(househld)

xtile incquint04= Einc04[pw=wtfactor], n(5)

*******
**** 05
*******


gen inc05 = hhincome_n

tab inc05 if inc05 == 17 & year == 2005
replace top = r(N)
tab inc05 if inc05 == 16 & year == 2005
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc05 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2005
replace inc05 = test if inc05 == 17 & year == 2005
replace inc05 = . if year != 2005
drop test

gen Einc05 = (inc05 ) /sqrt(househld)

xtile incquint05= Einc05[pw=wtfactor], n(5)

*******
**** 06
*******


gen inc06 = hhincome_n

tab inc06 if inc06 == 17 & year == 2006
replace top = r(N)
tab inc06 if inc06 == 16 & year == 2006
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc06 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2006
replace inc06 = test if inc06 == 17 & year == 2006
replace inc06 = . if year != 2006
drop test

gen Einc06 = (inc06 ) /sqrt(househld)

xtile incquint06= Einc06[pw=wtfactor], n(5)

*******
**** 07
*******


gen inc07 = hhincome_n

tab inc07 if inc07 == 17 & year == 2007
replace top = r(N)
tab inc07 if inc07 == 16 & year == 2007
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc07 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2007
replace inc07 = test if inc07 == 17 & year == 2007
replace inc07 = . if year != 2007
drop test

gen Einc07 = (inc07 ) /sqrt(househld)

xtile incquint07= Einc07[pw=wtfactor], n(5)

*******
**** 08
*******


gen inc08 = hhincome_n

tab inc08 if inc08 == 17 & year == 2008
replace top = r(N)
tab inc08 if inc08 == 16 & year == 2008
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc08 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2008
replace inc08 = test if inc08 == 17 & year == 2008
replace inc08 = . if year != 2008
drop test

gen Einc08 = (inc08 ) /sqrt(househld)

xtile incquint08= Einc08[pw=wtfactor], n(5)

*******
**** 09
*******


gen inc09 = hhincome_n

tab inc09 if inc09 == 17 & year == 2009
replace top = r(N)
tab inc09 if inc09 == 16 & year == 2009
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(56000) - ln(53000))
gen test = 56000* (1 + (V/(V - 1)))
drop V

recode inc09 (1 = 2000) (2 = 5000) ( 3 = 7000 ) ( 4= 9000) ( 5= 11000) ( 6= 13500) (7= 16500) (8=19000) ( 9=21500) ( 10=24500) (11=27500) (12 = 30500) (13 = 35000) (14 = 41000) (15 = 47000) (16=53000) (-1 97 98 99 = .) if year == 2009
replace inc09 = test if inc09 == 17 & year == 2009
replace inc09 = . if year != 2009
drop test

gen Einc09 = (inc09 ) /sqrt(househld)

xtile incquint09= Einc09[pw=wtfactor], n(5)




*******
**** 10
*******

gen inc10 = hhincome_n

tab inc10 if inc10 == 20 & year == 2010
replace top = r(N)
tab inc10 if inc10 == 19 & year == 2010
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(86600) - ln(76900))
gen test = 86600* (1 + (V/(V - 1)))
drop V

recode inc10 (1 = 3550) (2 = 8200) ( 3 = 10100 ) ( 4= 11750) ( 5= 13450) ( 6= 15250) (7= 17250) (8= 19450) ( 9=23000) ( 10=24500) (11=27500) (12 = 30500) (13 = 33900) (14 = 37650) (15 = 41900) (16=47050) (17=53550) (18=62200) (19=76900)  (-1 97 98 99 = .) if year == 2010
replace inc10 = test if inc10 == 20 & year == 2010
replace inc10 = . if year != 2010
drop test

gen Einc10 = (inc10 ) /sqrt(househld)

xtile incquint10= Einc10 [pw=wtfactor], n(5)






*******
**** 11
*******

gen inc11 = hhincome_n

tab inc11 if inc11 == 10 & year == 2011
replace top = r(N)
tab inc11 if inc11 == 9 & year == 2011
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(67200) - ln(58550))
gen test = 67200* (1 + (V/(V - 1)))
drop V

recode inc11 (1 = 4650) ( 2 = 10950 ) ( 3= 14400) (4=18400) ( 5= 23300) ( 6= 29050) (7= 35850 ) (8=47750 ) ( 9=58550) ///
 (-1 97 98 99 = .) if year == 2011
replace inc11 = test if inc11 == 10 & year == 2011
replace inc11 = . if year != 2011
drop test

gen Einc11 = (inc11 ) /sqrt(househld)

xtile incquint11= Einc11[pw=wtfactor], n(5)



*******
**** 12
*******

gen inc12 = hhincome_n

tab inc12 if inc12 == 10 & year == 2012
replace top = r(N)
tab inc12 if inc12 == 9 & year == 2012
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(67200) - ln(58550))
gen test = 67200* (1 + (V/(V - 1)))
drop V

recode inc12 (1 = 4650) ( 2 = 10950 ) ( 3= 14400) (4=18400) ( 5= 23300) ( 6= 29050) (7= 35850 ) (8=47750 ) ( 9=58550) ///
 (-1 97 98 99 = .) if year == 2012
replace inc12 = test if inc12 == 10 & year == 2012
replace inc12 = . if year != 2012
drop test

gen Einc12 = (inc12 ) /sqrt(househld)

xtile incquint12= Einc12[pw=wtfactor], n(5)


*******
**** 13
*******

gen inc13 = hhincome_n

tab inc13 if inc13 == 10 & year == 2013
replace top = r(N)
tab inc13 if inc13 == 9 & year == 2013
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(67200) - ln(58550))
gen test = 67200* (1 + (V/(V - 1)))
drop V

recode inc13 (1 = 4650) ( 2 = 10950 ) ( 3= 14400) (4=18400) ( 5= 23300) ( 6= 29050) (7= 35850 ) (8=47750 ) ( 9=58550) ///
 (-1 97 98 99 = .) if year == 2013
replace inc13 = test if inc13 == 10 & year == 2013
replace inc13 = . if year != 2013
drop test

gen Einc13 = (inc13 ) /sqrt(househld)

xtile incquint13= Einc13[pw=wtfactor], n(5)




*******
**** 14
*******

gen inc14 = hhincome_n

tab inc14 if inc14 == 10 & year == 2014
replace top = r(N)
tab inc14 if inc14 == 9 & year == 2014
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(67200) - ln(58550))
gen test = 67200* (1 + (V/(V - 1)))
drop V

recode inc14 (1 = 4650) ( 2 = 10950 ) ( 3= 14400) (4=18400) ( 5= 23300) ( 6= 29050) (7= 35850 ) (8=47750 ) ( 9=58550) ///
 (-1 97 98 99 = .) if year == 2014
replace inc14 = test if inc14 == 10 & year == 2014
replace inc14 = . if year != 2014
drop test

gen Einc14 = (inc14 ) /sqrt(househld)

xtile incquint14= Einc14[pw=wtfactor], n(5)



*******
**** 15
*******

*******
gen inc15 = hhincome_n

tab inc15 if inc15 == 20 & year == 2015
replace top = r(N)
tab inc15 if inc15 == 19 & year == 2015
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(86600) - ln(76900))
gen test = 86600* (1 + (V/(V - 1)))
drop V

recode inc15 (1 = 3550) (2 = 8200) ( 3 = 10100 ) ( 4= 11750) ( 5= 13450) ( 6= 15250) (7= 17250) (8= 19450) ( 9=23000) ( 10=24500) (11=27500) (12 = 30500) (13 = 33900) (14 = 37650) (15 = 41900) (16=47050) (17=53550) (18=62200) (19=76900)  (-1 97 98 99 = .) if year == 2015
replace inc15 = test if inc15 == 20 & year == 2015
replace inc15 = . if year != 2015
drop test

gen Einc15 = (inc15 ) /sqrt(househld)

xtile incquint15= Einc15[pw=wtfactor], n(5)


*******
**** 16
*******

gen inc16 = hhincome_n

tab inc16 if inc16 == 20 & year == 2016
replace top = r(N)
tab inc16 if inc16 == 19 & year == 2016
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(86600) - ln(76900))
gen test = 86600* (1 + (V/(V - 1)))
drop V

recode inc16 (1 = 3550) (2 = 8200) ( 3 = 10100 ) ( 4= 11750) ( 5= 13450) ( 6= 15250) (7= 17250) (8= 19450) ( 9=23000) ( 10=24500) (11=27500) (12 = 30500) (13 = 33900) (14 = 37650) (15 = 41900) (16=47050) (17=53550) (18=62200) (19=76900)  (-1 97 98 99 = .) if year == 2016
replace inc16 = test if inc16 == 20 & year == 2016
replace inc16 = . if year != 2016
drop test

gen Einc16 = (inc16 ) /sqrt(househld)

xtile incquint16= Einc16[pw=wtfactor], n(5)


*******
**** 17
*******

gen inc17 = hhincome_n

tab inc17 if inc17 == 10 & year == 2017
replace top = r(N)
tab inc17 if inc17 == 9 & year == 2017
replace top_1 = r(N)

gen V= (ln(top_1+ top) - ln(top))/(ln(67200) - ln(58550))
gen test = 67200* (1 + (V/(V - 1)))
drop V

recode inc17 (1 = 4650) ( 2 = 10950 ) ( 3= 14400) (4=18400) ( 5= 23300) ( 6= 29050) (7= 35850 ) (8=47750 ) ( 9=58550) ///
 (-1 97 98 99 = .) if year == 2017
replace inc17 = test if inc17 == 10 & year == 2017
replace inc17 = . if year != 2017
drop test

gen Einc17 = (inc17 ) /sqrt(househld)

xtile incquint17= Einc17[pw=wtfactor], n(5)









*** Merge into one variable hhincqE

gen hhincqE = .

local i=83
while `i' <= 87{
capture replace hhincqE = incquint`i' if year == 19`i'

local i = `i'+1
}

local i=89
while `i' <= 91{
capture replace hhincqE = incquint`i' if year == 19`i'

local i = `i'+1
}


local i=93
while `i' <= 99{
capture replace hhincqE = incquint`i' if year == 19`i'

local i = `i'+1
}

local i=1
while `i' <= 9{
capture replace hhincqE = incquint0`i' if year == 200`i'

local i = `i'+1
}


local i=10
while `i' <= 17{
capture replace hhincqE = incquint`i' if year == 20`i'

local i = `i'+1
}

tab hhincqE year, missing

